// 定义Schema并创建model
const mongoose = require('./db');
const {getCurrentTime} = require('../utils')
const NewsSchema = new mongoose.Schema({
    news_id: {
        type: Number,
        required: [true, '新闻id不为空'],
        unique: true
    },
    news_title: {
        type: String,
        required: [true, '新闻id不为空'],
        minLength: [5, '新闻标题长度不能小于5']
    },
    post_time: {
        type: Date,
        required: [true, '发布时间不为空']
    },
    news_img: {
        type: String,
        required: [true, '上传图片不为空']
    },
    news_link: {
        type: String,
        required: [true, '新闻连接不为空']
    },
    img_original_name: {
        type: String,
        required: false
    },
    news_summary: {
        type: String,
        required: false
    },
    hits: {
        type: Number,
        default: 0
    },
    create_at:{
        type: String
    },
    update_at:{
        type: String
    },
    status: {
        type: Number,
        default: 1
    }
});

module.exports = mongoose.model('News', NewsSchema, 'news');